<!doctype html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <meta content="always" name="referrer">
    <#include "../common/header.html">

</head>
<body>
<!--最外面的灰底框,用于与ifram区别开-->
<div class="col-xs-12 lightgray_div">
    <!--白底框-->
    <div class="col-xs-12 white_div">
        <!--返回按钮-->
        <h4 class="back_div"><a href="javascript:history.back()" style="font-size: 16px; color: black; ">< 返回</a></h4>
        <div class="row all_input_div" style="margin-top: 8px">
            <div class="col-xs-6">
                <form class="form-horizontal"  role="form" id="form1">
                    <input type="hidden" name="id" id="id" value="${id!?html}"/>

                    <div class="form-group">
                        <label class="col-xs-2 control-label"><em class="text-red">*</em>菜单名称</label>
                        <div class="col-xs-10">
                            <input type="text" class="form-control input_50b" id="name" name="name"
                                   placeholder="菜单名称">
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="col-xs-2 control-label"><em class="text-red">*</em>菜单编码</label>
                        <div class="col-xs-10">
                            <input type="text" class="form-control input_50b" id="code" name="code"
                                   placeholder="菜单编码">
                        </div>
                    </div>



                    <div class="form-group">
                        <label class="col-xs-2 control-label">父菜单</label>
                        <div class="col-xs-10">
                            <select class="form-control input_50b" name="parent_id" id="parent_id">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-xs-2 control-label"><em class="text-red">*</em>菜单路径</label>
                        <div class="col-xs-10">
                            <input type="text" class="form-control input_50b" id="url" name="url"
                                   placeholder="路径">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-xs-2 control-label"><em class="text-red">*</em>排序号</label>
                        <div class="col-xs-10">
                            <select class="form-control input_50b" name="orderno" id="orderno">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group ">
                        <label class="col-xs-2 control-label"><em class="text-red">*</em>菜单类型</label>
                        <div class="col-xs-10 form-radio-div ">
                            <label class="form-radio-label"><input name="type"  type="radio"  value="1">系统</label>
                            <label class="form-radio-label"><input name="type"  type="radio"  value="2">父级菜单</label>
                            <label class="form-radio-label"><input name="type"  type="radio"  value="3">菜单</label>
                            <label class="form-radio-label"><input name="type"  type="radio"  value="4">按钮</label>
                            <label class="form-radio-label"><input name="type"  type="radio"  value="5">资源</label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-xs-2 control-label">图标</label>
                        <div class="col-xs-10">
                            <input type="text" class="form-control input_50b" id="icon_uri" name="icon_uri"
                                   placeholder="图标">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-xs-2 control-label">菜单参数</label>
                        <div class="col-xs-10">
                            <textarea type="text" class="form-control input_50b" style="height:120px;resize:none;"
                                      id="para" name="para"></textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-xs-2 control-label">说明</label>
                        <div class="col-xs-10">
                            <textarea type="text" class="form-control input_50b" style="height:120px;resize:none;"
                                      id="remark" name="remark"></textarea>
                        </div>
                    </div>

                </form>
                <div class="form-group ">
                    <label class="col-xs-2 control-label"></label>
                    <a class="gbn gbn-m" href="javascript:" id="btn_save" onclick="E.save();">保存</a>
                    <a class="gbn gbn-m gbn-red" href="javascript:" onclick="history.back();">返回</a>
                </div>
            </div>
        </div>
    </div>
</div>

</body>
<#include "../common/layui_init.html">
<script type="text/javascript">

    var E = {
        save: function () {
            $.post("${request.contextPath}/menu/add_or_edit",$("#form1").serialize(), function (o) {
                if (o.code == 0) {
                    layer.msg(o.message);
                    location.href = document.referrer;
                } else {
                    layui_layer.error_alert(o.message);
                }
            });

        },
        load: function () {
            $.getJSON("${request.contextPath}/menu/getById", {id: $("#id").val()}, function (o) {
                if (o.code == 0) {
                    $("#form1").setFormValues(o.data);
                }
            });
        },
        load_orderno:function(label_id,placeholder){
            var sele="#"+label_id;
            //清空下拉框
            // $(sele).empty();
            var html="<option value=\"\">"+placeholder+"</option>";
            for(var i=1;i<=50;i++){
                var temp="<option value=\""+i+"\">"+i+"</option>"
                html+=temp;
            }
            $(sele).html(html);
        }

    }
    $(function () {
        //回车点击事件 保存
        enter_event.event_save_click();
        $.ajaxSettings.async=false;
        E.load_orderno('orderno',"请选择排序号")
        select2_utils.load_select2_key_id("parent_id","请选择父菜单","${request.contextPath}/menu/getAll",
            {exclude_id:'${id!?html}'},"name","code","id","无父菜单");
        var id = $("#id").val()
        if (id != null && id != "") {
            E.load();
        }

    });
</script>
<#include "../common/footer-inner.html">
</html>
